<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="black" name="apple-mobile-web-app-status-bar-style">
<meta content="telephone=no" name="format-detection">
<meta content="email=no" name="format-detection">
<title>向商户付款</title>
<link rel="stylesheet" href="{{asset('/payviews/css/style.css')}}">
<link rel="stylesheet" href="{{asset('/phone/css/swiper.min.css')}}">
<script type="text/javascript" src="{{asset('/phone/js/Screen.js')}}"></script>
<style>
    .pay_money {
        border: 1px solid #E60012;
    }
    .swindle {
        width: 100% !important;
        height: .6rem !important;
        font-size: .24rem !important;
    }
    .keyboard ul li.swindle:after {
        font-size: .24rem !important;
    }
    .red{
        background-color: #E60012;
    }
    .payment{width:100%;overflow: hidden;background-color: #fff;}

    .payment .store_info {width:90%;margin:0 auto;padding:.3rem 0 .4rem;display: flex;justify-content: space-between;align-items: center;}

    .payment .store_info .title{width:100%;height:1.2rem;line-height: 1.2rem;}

    .payment .store_info .title img{width:1.2rem;height:1.2rem;vertical-align:middle;padding-right: .2rem;border-radius: 50%;}

    .payment .store_info .scan{ border-radius: 5px; height: 32px; line-height: 32px;background: #b7dcfc;border: 0px; font-size: 0.24rem; padding: 0 0.12rem;width: 1rem;}
    /* 选择商品 */
    .selgoods_wrap{ border-top-left-radius: 0.75rem;border-top-right-radius: 0.75rem;background: rgb(255, 255, 255);z-index: 1202;transform: translateZ(0);opacity: 1;visibility: visible;position: fixed;left: 0;right: 0;bottom: 365px;transform: translate3d(0, 100%, 0);transition: all .3s ease-in-out;min-height: 365px;}

    .selgoods_header{ background: rgb(255, 255, 255);border-top-left-radius: 0.25rem;border-top-right-radius: 0.25rem;text-align: center;padding: 0.15rem 0; }

    .selgoods_header-text{ font-size: 0.30rem;color: rgb(24, 24, 24);font-weight: 400;text-align: center;width: 100%;white-space: nowrap;overflow: hidden;box-sizing: border-box;text-overflow: ellipsis;flex: 1; }

    .selgoods_header-close{ position: absolute;right: 0.35rem;top: 0.14rem;text-align: right;cursor: pointer; }

    .selgoods_header-close img{ width:24px;height:24px }

    .selgoods_scroll{ height: 320px;width: 100%;overflow-y: scroll; }

    .selgoods_content{ display: flex;padding: 0.25rem 0.25rem;justify-content: space-between;align-items: center;border-top: 1px solid rgb(238, 238, 238); }

    .selgoods_content_text{ display: flex; }

    .selgoods_content_text img{ width: 32px;height: 32px;margin-right: 0.15rem;display: inline;border-radius: 2px; }

    .selgoods_content_text-title{ font-size: 0.28rem;font-weight: 600; }

    .selgoods_content_text-code{ font-size: 0.25rem;color:#666666;margin-top: 0.04rem; }

    .selgoods_content_btn{ height: 25px;line-height: 26px;background: #b7dcfc;border: 0px;font-size: 0.24rem;padding: 0 0.12rem;width: 1rem;border-radius: 14px; }
        .goods{ margin-top:10px;background:#fff;padding: 0.1rem 0.25rem; }
    .goods .goods-item{padding:0.1rem 0;} 
    .product {
        border-bottom: 1px solid #ddd;
        padding: 10px;
        position: relative;
        height: 60px;
    }
    .product img {
        width: 50px;
        height: 50px;
        float: left;
        margin-right: 10px;
        border-radius: 2px;
    }
    .product-info {
        overflow: hidden;
    }
    .product-info p{
        font-size: 0.28rem;
        font-weight: 600;
    }
    .product-info .desc{
        font-size: 0.24rem;
        color:#666666;
        margin-top: 1px;
    }
    .product-name {
        margin: 0;
    }
    .product-action {
        position: absolute;
        right: 10px;
        top: 10px;
        text-align: right;
    }
    .product-action .layui-btn{
        height: 20px;
        line-height: 20px;
        background: #b7dcfc;
        border-radius: 4px;
        border: 0px;
        font-size: 0.30rem;
        padding: 0 0.12rem;
        text-align: center;
        vertical-align: bottom;
    }
    .product-action .delbtn{
        font-size: 0.22rem;
        margin-bottom:12px;
        color: #fff;
        background: #b2b2b2;
    }
    .product .editbtn{
        width:22px
    }
    .product .deaddbtn{
        line-height:0px;
    }
    .product-action .curnum{
        margin:0 6px;
    }
    .total-action{
        text-align: right;
        padding: 10px 0;
    }
    .total-action .totalprice-action{
        width: 100px;
        height: 32px;
        color: #fff;
        line-height: 32px;
        background: #ff3a50;
        border-radius: 20px;
        border: 0px;
        font-size: 0.26rem;
        padding: 0 0.12rem;
        text-align: center;
        vertical-align: bottom;
    }
</style>
</head>
<!--
    通用说明：
    1.模块的隐藏添加class:hide;
    2.body标签默认绑定ontouchstart事件，激活所有按钮的:active效果
-->
<body>
    <form>
        <div class="payment">
            <!-- <div class="title">
                <img src="{{url('/payviews/img/touxiang.png')}}">{{$data['store_name']}}
            </div> -->
            <div id="storeinfo" class="store_info">
                <div class="title">
                    <img src="{{url('/payviews/img/touxiang.png')}}">{{$data['store_name']}}
                </div>
                <div style="display:flex">
                    <button type="button" id="scanQRButton" class="layui-btn scan" style="border-radius:5px">扫一扫</button>
                    <button type="button" id="selGoodsButton" class="layui-btn scan" style="border-radius:5px;margin-left:6px">选一选</button>
                </div>
            </div>
            <!-- 条形码扫描 -->
            <div id="code-modal" style="display:none">
                <video id="video" style="height:100%;width:100%"></video> 
            </div>
            <div class="pay_money">
                <span>支付金额</span>
                <i></i>
                <div class="ipt"> ￥ <span id="total_amount"></span></div>
            </div>
            <div class="remark">
                <textarea class="remark_con" id="remark" placeholder="添加备注(30字以内)"></textarea>
                <img src="{{url('/payviews/img/qingkong.png')}}" class="quxiao">
            </div>
        </div>

        <input type="hidden" id="csrf_token" value="{{csrf_token()}}">
        <input type="hidden" id="store_id" value="{{$data['store_id']}}">
        <input type="hidden" id="merchant_id" value="{{$data['merchant_id']}}">
        <input type="hidden" id="open_id" value="{{$data['open_id']}}">
        <input type="hidden" id="is_goods" value="{{$data['is_goods']}}">
    </form>

    <div class="keyboard">
        <ul>
            <li data="1"></li>
            <li data="2"></li>
            <li data="3"></li>
            <!-- <li class="xyk_pay" data="信用卡分期"></li> -->
            <li class="confirm" data="确认"><input type="button" id="tijiao"></li>
            <li data="4"></li>
            <li data="5"></li>
            <li data="6"></li>
            <li data="7"></li>
            <li data="8"></li>
            <li data="9"></li>
            <li data="0"></li>
            <!-- <li class="disable_li"></li> -->
            <li data="."></li>
            <li class="del"><img src="{{url('/payviews/img/tui.png')}}"></li>
        </ul>
    </div>
    <div class="load-hidden"></div>
    <div class="load-hiddenbg" style="display: none"></div>

    <!-- 提示 -->
    <div class="mask" style="display: none;">
        <div class="popup_bg"></div>
        <div class="result_layer" id="accountMsg">
            <div style="padding: .5rem 0;">
                <p style="font-size:.35rem;height: .6rem;font-weight: 500;">提示</p>
                <p class="tip"></p>
            </div>
            <a class="qr" style="width:100%;border-left:1px solid #ccc;color:#219aff">我知道了</a>
        </div>
    </div>

    <!-- 弹框 -->
    <!-- <div class="show" style="display: block">
        <div class="popup_bg"></div>
        <div class="result_layer" id="accountMsg">
        <div style="padding: .48rem 0;">
            <p style="font-size:.35rem;height: .6rem;font-weight: 500;">温馨提示</p>
            <p>请确认是门店付款，谨防网络诈骗</p>
        </div>
        <a class="qd" style="width:100%;border-left:1px solid #ccc;color:#219aff">我知道了</a>
        </div>
    </div> -->
    <!-- 商品列表 -->
    <div class="goods" style="display:none">
        <div id="goods-list"></div>
        <div class="total-action"><button id="settlepay" class="layui-btn totalprice-action">去结算(<label class="totalNum">1</label>)</button></div>
    </div>
    <div class="load-hidden"></div>
    <div class="load-hiddenbg" style="display: none"></div>
    <!-- 商品列表弹框显示 -->
    <div id="selGoods" style="display:none">
        <div class="popup_bg" id="selGoods_mask">
        </div>
        <div class="selgoods_wrap">
            <div class="selgoods_header">
                <label class="selgoods_header-text">请选择商品</label>
                <div class="selgoods_header-close"><img src="{{url('/payviews/img/close.png')}}"></div>
            </div>
            <div id="selgoodslist" class="selgoods_scroll"></div>
        </div>
    </div>
</body>
</html>
<script type="text/javascript" src="{{asset('/phone/js/jquery-2.1.4.js')}}"></script>
<script type="text/javascript" src="{{asset('/phone/js/swiper.jquery.min.js')}}"></script>
<script src="{{asset('/phone/js/fastclick.js')}}"></script>
<script>
    $(function () {
        FastClick.attach(document.body);
    });

    document.documentElement.addEventListener('dblclick', function (e) {
        e.preventDefault();
    });

    document.addEventListener('touchmove', function (event) {
        event.preventDefault();
    }, false);

    document.addEventListener('touchmove', function (e) {
        e.preventDefault()
    }, false);
</script>
<script>
    $('.keyboard ul li').on("touchend", function () {
        var _this = $(this);
        var num = _this.attr('data');
        var $money = $("#total_amount");
        var oldValue = $money.html();
        var newValue = "";

        if (_this.hasClass('del')) {
            newValue = oldValue.substring(0, oldValue.length - 1);
            if (newValue == "") {
                newValue = "";
                $('.confirm').removeClass('red');
            }

            $money.html(newValue);
        }
        else {
            if (oldValue == "0.00") {
                if (num != ".") {
                    oldValue = "";
                }
            }
            if (oldValue == "0") {
                if (num != ".") {
                    oldValue = "";
                }
            }
            if (oldValue == "") {
                if (num == ".") {
                    oldValue = "0.";
                }
            }
            newValue = oldValue + num;

            //控制输入的值为五位数和2位小数点
            reg = /^\d{0,8}(\.\d{0,2})?$/g;

            if (reg.test(newValue)) {
                $money.html(newValue);
                $('.confirm').addClass('red');
            } else {
                $money.html(oldValue);
                $('.confirm').addClass('red');
            }

            // 信用卡分期
            if (newValue >= 600 && newValue <= 50000) {
                $('.xyk_pay').addClass('fenqi');
            }
        }
    });

    // 信用卡分期star-----------------------------
    $('.keyboard').on("click", "ul li.fenqi", function () {
        var undertake = 1;
        var price = $('#total_amount').html();
        var store_id = $('#store_id').val();
        var m_id = $('#merchant_id').val();
        var open_id = $('#open_id').val();

        window.location.href = "{{url('/phone/stages?undertake=')}}" + undertake + "&price=" + price + "&store_id=" + store_id + "&m_id=" + m_id;
    });
    // 信用卡分期end-----------------------------

    $(document).ready(function () {
        var swiper = new Swiper('.swiper-container', {
            pagination: '.swiper-pagination',
            paginationClickable: true
        });
    });

    $(".remark_con").focus(function () {
        $('.keyboard').hide();
    });

    $('.pay_money').click(function () {
        $('.keyboard').show();
    });

    $(".remark_con").bind("input propertychange", function () {
        var len = $(this).val().length;
        var max = 30;

        if (len > max) {
            var value = $(this).val().substring(0, max);
            $(this).val(value);
        }
    });

    $('.quxiao').click(function () {
        $('.remark_con').val('');
    });

    $('.remark_con').blur(function () {
        $('.keyboard').show();
    });
</script>
<script type="text/javascript">
    var jump_success = "{{url('weixin/order/success')}}";
    var jump_fail = "{{url('weixin/order/fail')}}";

    $(function () {
        function onBridgeReady() {
            var url = "{{url('/api/merchant/qr_auth_pay')}}";
            var data = {
                "total_amount": $("#total_amount").html(),
                "remark": $("#remark").val(),
                "store_id": $("#store_id").val(),
                "merchant_id": $("#merchant_id").val(),
                "_token": $("#csrf_token").val(),
                "open_id": $('#open_id').val(),
                "ways_type": '13004'
            };

            $.post(url, data, function (back) {
                $('.load-hidden').removeClass('loading');
                $('.load-hiddenbg').hide();
                var data_url = "&total_amount=" + $("#price").html() + "&store_id=" + $("#store_id").val();
                if (back.status == 1) {
                    window.location.href = back.data.redirectUrl;
                }
                else {
                    $('.mask').show();
                    window.location.href = "{{url('page/pay_errors?message=')}}" + back.message + data_url;
                }

            }, "json");
        }

        // 触发支付事件
        $('#tijiao').click(function () {
            $('.load-hidden').addClass('loading');
            $('.load-hiddenbg').show();
            $(this).attr('disabled', 'disabled');
            onBridgeReady()
        })

    });

    $('.qr').click(function () {
        $('.mask').hide();
        location.reload();
    });

    $('.qd').click(function () {
        $('.show').hide();
        localStorage.setItem("show", '1');
    });

    var show = localStorage.getItem("show");
    if (show == 1) {
        $('.show').hide();
    } else {
        $('.show').show();
    }

</script>
<script type="text/javascript" src="{{asset('/layuiadmin/layui/layui.js')}}"></script>
<script type="text/javascript" src="{{asset('/payviews/js/zxing.min.js')}}"></script>
<script>
    layui.use('layer', function(){ 
    var $ = layui.jquery, layer = layui.layer; 
    // 扫一扫显示与隐藏
    const isGoodsShow = $("#is_goods").val()
    if(isGoodsShow == 1){
        $("#scanQRButton").show()
        $("#selGoodsButton").show()
    }else{
        $("#scanQRButton").hide()
        $("#selGoodsButton").hide()
        $("#addClass").addClass('storecenter')
    }
    var goodsList = [] 
    let selectedDeviceId;
    const codeReader = new ZXing.BrowserMultiFormatReader()
    console.log(codeReader,'codeReader---------')
    console.log(codeReader.reset(),'codeReader.reset()---------')
        codeReader.listVideoInputDevices()
        .then((videoInputDevices) => {
          const sourceSelect = document.getElementById('sourceSelect')
          selectedDeviceId = videoInputDevices.length>0?videoInputDevices[0].deviceId:''
          if (videoInputDevices.length > 1) {
            selectedDeviceId = videoInputDevices[1].deviceId
          }
          document.getElementById('scanQRButton').addEventListener('click', () => {
                    // 成功访问摄像头，开始扫描
                    var layerCode = layer.open({
                        type: 1,
                        title: false, // 去掉标题栏
                        closeBtn: 1, // 允许关闭按钮
                        area: ['300px', '300px'],
                        content: $('#code-modal'), 
                        yes: function(index, layero){
                            // 当你点击按钮时关闭弹窗
                            layer.close(index);
                            $('#scanQRButton').prop("disabled", false);
                        },
                        end: function(){
                            layerCloseClick()
                            $('#scanQRButton').prop("disabled", false);
                        }
                        
                    })
                    codeReader.decodeFromVideoDevice(selectedDeviceId, 'video', (result, err) => {
                        if (result) {
                            console.log(result)
                            // let istrueText = /^69/.test(result.text)
                            // if(istrueText===true){
                            //     getGoodsInfo(result.text)
                            // }
                            // 2025.5.26去除69码判断限制
                            getGoodsInfo(result.text)
                        }
                        if (err && !(err instanceof ZXing.NotFoundException)) {
                            console.error(err)
                            document.getElementById('result').textContent = err
                        }
                    })
          })

        })
        .catch((err) => {
            console.error(err)
        })
  
        
    function getGoodsInfo(code){
        layer.closeAll()
        var loading = layer.load(2, {
            shade: [0.2,'#fff'],
            content: '识别中...', 
            success: function (obj) {
                obj.find('.layui-layer-content').css({
                    'padding-top': '40px', // 图标与样式会重合，这样设置可以错开
                    'width': '200px' // 文字显示的宽度
                });
            }
        });
        var codeurl = "{{url('/api/user/goods_info')}}";
        var codeinfo =
        {
            "store_id": $("#store_id").val(),
            "code":code
        };
        $.post(codeurl, codeinfo,function (res) {
            if(res.status == 1){
                $(".goods").show()
                layer.close(loading)
                layer.msg('商品识别成功', {
                    icon: 1
                    ,time: 3000
                });
                layerCloseClick()
                $(".keyboard").hide()
                let isExistIndex = goodsList.findIndex(ele=>ele.code == res.data.code)
                if(isExistIndex === -1 ){
                    res.data['curnum'] = 1
                    goodsList.unshift(res.data)
                    $('#goods-list').html('')
                    goodsListHandle()
                    getTotalPrice()
                    getTotalPriceNum()
                }else{
                    layer.closeAll()
                    layer.msg('当前商品已在列表中，请手动添加数量', {
                        icon: 2
                        ,time: 3000
                    });
                    $('#scanQRButton').prop("disabled", false);
                }
            }
            if (res.status == -1) {
                layer.closeAll()
                layer.msg(res.message, {
                    icon: 2
                    ,time: 3000
                });
                $('#scanQRButton').prop("disabled", false);
            }
        })
    }
    // 商品列表有值时，金额键盘隐藏，否则显示
    $('.pay_money').click(function () {
        isGoodsKeywordShow()
    });
    // 商品列表有值时，金额键盘隐藏，否则显示
    function isGoodsKeywordShow(){
        if(goodsList.length>0){
            $('.keyboard').hide();
            $(".goods").show()
        }else{
            $('.keyboard').show();
            $(".goods").hide()
        }
    }
    var list = $('#goods-list');
    //商品列表渲染
    function goodsListHandle(){
        var list = $('#goods-list');
        var html=''
        for( var i = 0; i < goodsList.length; i++ ){
            html += '<div class="product "><img src="' +goodsList[i].img +'" /><div class="product-info"><p>'+goodsList[i].title+'</p><p class="desc">'+goodsList[i].code+'</p><p class="desc">金额:'+goodsList[i].price+'</p></div>';
            html += '<div class="product-action" data-id='+ i +'><button class="layui-btn delbtn">删除</button><br/><button class="layui-btn editbtn deaddbtn">-</button><label class="curnum">'+goodsList[i].curnum+'</label><button class="layui-btn editbtn addbtn">+</button></div>';
            html +='</div>'
        }
        list.html(html);
    }
    // 计算商品总金额
    function getTotalPrice(){
        const totalPrice = goodsList.reduce((total, item) => total + item.price * item.curnum, 0)
        $("#total_amount").text(totalPrice.toFixed(2))
    }
    //获取商品总数量
    function getTotalPriceNum(){
        const totalPriceNum = goodsList.reduce((total, item) => total + item.curnum , 0)
        $(".totalNum").text(totalPriceNum.toFixed(0))
    }
    //商品列表删除事件
    list.on('click', '.delbtn', function() {
        var dataid = $(this).parent().data('id')
        $(this).parent().parent().remove(); // 删除包含按钮的列表项
        goodsList.splice(dataid, 1);
        $('#goods-list').html('')
        getTotalPrice()
        getTotalPriceNum()
        if(goodsList.length>0){
            goodsListHandle()
        }else{
            $(".goods").hide()
            $('.keyboard').show();
            $("#total_amount").html('')
        }
        
    });
    // 商品添加数量
    list.on('click', '.addbtn', function() {
        let dataids = 0
        dataids = $(this).parent().data('id')
        var goodsItem = goodsList[dataids]
        goodsItem.curnum ++
        $('.curnum').eq(dataids).text(goodsItem.curnum)
        getTotalPrice()
        getTotalPriceNum()
        // 2025.5.22 要求商品数量不限制
        // if(goodsItem.curnum < goodsItem.num){
        //     goodsItem.curnum ++
        //     $('.curnum').eq(dataids).text(goodsItem.curnum)
        //     getTotalPrice()
        //     getTotalPriceNum()
        // }else{
        //     layer.msg('当前商品数量已达最大', {
        //         icon: 2
        //         ,time: 3000
        //     });
        // }
    })
    // 商品减少数量
    list.on('click', '.deaddbtn', function() {
        var dataid = $(this).parent().data('id')
        var goodsItem = goodsList[dataid]
        if(goodsItem.curnum > 1){
            goodsItem.curnum --
            $('.curnum').eq(dataid).text(goodsItem.curnum)
            getTotalPrice()
            getTotalPriceNum()
        }else{
            layer.msg('当前商品数量不能再减少了', {
                icon: 2
                ,time: 3000
            });
        }
    })

  // 触发支付事件
  $('#settlepay').on('click',function(){
    console.log('去结算-------------')
        $('.load-hidden').addClass('loading');
        $('.load-hiddenbg').show();
        $(this).attr('disabled', 'disabled');
        let goods = []
        goodsList.forEach(ele=>{
            goods.push({
                goods_name:ele.title,
                count:ele.curnum,
                goods_price:ele.price,
                goods_code:ele.code
            })
        })
        let goodsJson = JSON.stringify(goods)
        console.log(JSON.stringify(goods),'goods')
        onBridgeReady(goodsJson)
    })
    function onBridgeReady(goods) {
        var url = "{{url('/api/merchant/qr_auth_pay')}}";
        var data =
            {
                "total_amount": $("#total_amount").html(),
                "remark": $("#remark").val(),
                "store_id": $("#store_id").val(),
                "merchant_id": $("#merchant_id").val(),
                "_token": $("#csrf_token").val(),
                "open_id": $('#open_id').val(),
                "ways_type": '13004',
            };
        if(goods){
            data['goods'] = goods;
        }
        console.log(data);

        $.post(url, data, function (back) {
            $('.load-hidden').removeClass('loading');
            $('.load-hiddenbg').hide();
            var data_url = "&total_amount=" + $("#price").html() + "&store_id=" + $("#store_id").val();
            if (back.status == 1) {
                window.location.href = back.data.redirectUrl;
            }
            else {
                $('.mask').show();
                window.location.href = "{{url('page/pay_errors?message=')}}" + back.message + data_url;
            }

        }, "json");

    }
    //关闭识别
    function layerCloseClick(){
        codeReader.reset()
    }
    //商品列表
    var goodsAllList = []
    function getGoodsList(){
        var codeurl = "{{url('/api/user/goods_lists')}}";
        var codeinfo =
        {
            "store_id": $("#store_id").val(),
        };
        $.post(codeurl, codeinfo,function (res) {
            if(res.status == 1){
                goodsAllList = res.data || [];
            }
            if (res.status == -1) {
                goodsAllList = []
            }
           
        })
    }
    getGoodsList()
    // 点击选择-商品
    $("#selGoodsButton").click(function(){
        layer.closeAll()
        $('#selGoodsButton').prop("disabled", true);
        let html=''
        if(goodsAllList.length>0){
            for( var i = 0; i < goodsAllList.length; i++ ){
            html += `<div class="selgoods_content">
                    <div class="selgoods_content_text">
                        <img src="${goodsAllList[i].img}">
                        <div>
                            <p class="selgoods_content_text-title">${goodsAllList[i].title}</p>
                            <p class="selgoods_content_text-code">${goodsAllList[i].code}</p>
                        </div>
                    </div>
                    <button class="selgoods_content_btn" data-index="${i}">选择</button>
                </div>`
            }
            $('#selgoodslist').html(html);
            $(".keyboard").hide()
            $("#selGoods").show()
        }else{
            layer.closeAll()
            layer.msg('当前门店下暂无商品', {
                icon: 2
                ,time: 3000
            });
        }
       
    })
    //商品列表-点击选择
    $('#selgoodslist').on('click', '.selgoods_content_btn', function() {
        console.log(goodsAllList,'goodsAllList--')
        let dataindex = $(this).data('index')
        var selGoodsItem = goodsAllList[dataindex]
        let isExistIndex = goodsList.findIndex(ele=>ele.code == selGoodsItem.code)
        if(isExistIndex === -1 ){
            selGoodsItem['curnum'] = 1
            goodsList.unshift(selGoodsItem)
            selGoodsClose()
            $('#goods-list').html('')
            goodsListHandle()
            getTotalPrice()
            getTotalPriceNum()
            
        }else{
            layer.closeAll()
            layer.msg('当前商品已在列表中，请手动添加数量', {
                icon: 2
                ,time: 3000
            });
        }
    })
    //选择商品弹框-点击遮罩关闭
    $("#selGoods_mask").click(function(){
        selGoodsClose()
    })
    //选择商品弹框-点击关闭按钮
    $(".selgoods_header-close").click(function(){
        selGoodsClose()
    })
    //商品列表关闭
    function selGoodsClose(){
        $("#selGoods").hide()
        $('#selGoodsButton').prop("disabled", false);
        isGoodsKeywordShow()
    }
})

</script>
